package com.elive.service.impl;

import com.elive.common.ServerResponse;
import com.elive.dao.ServiceMapper;
import com.elive.service.IServiceService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by wuyin on 2018/3/13.
 */
@Service("iServiceService")
public class ServiceServiceImpl implements IServiceService{

    @Autowired
    private ServiceMapper serviceMapper;

    @Override
    public ServerResponse<PageInfo> getServiceList(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<com.elive.pojo.Service> serviceList = serviceMapper.selectServiceList();
        if(serviceList.size() != 0){
            PageInfo pageResult = new PageInfo(serviceList);
            return ServerResponse.createBySuccess(pageResult);
        }else {
            return ServerResponse.createByErrorMessage("没有服务记录");
        }
    }
}
